/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package slisfx.xml;

import java.util.HashMap;

/**
 *
 * @author Rebecca
 */
public class XMLEncoder {

	private static HashMap<String, String> codes;
	static {
		codes = new HashMap<String, String>();
		codes.put("\"", "&quot;");
		codes.put("&", "&amp;");
		codes.put("'", "&apos;");
		codes.put("<", "&lt;");
		codes.put(">", "&gt;");
	}
	
	private XMLEncoder(){}
	
	/**
	 * Receives string input and returns a new encoded string.
	 */
	public static String encode(String input) {
		for(String x : codes.keySet()) {
			input = input.replace(x, codes.get(x));
		}
		return input;
	}
	
}